//Code by Daylife
#include <bits/stdc++.h>
using namespace std;

int n, m, L, V, p[100005];

struct car{
    int l, r;
}ca[100005];

bool cmp(car a, car b){
    if(a.r!=b.r) return a.r<b.r;
    else return a.l<b.l;
}

int main(){
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    int t;
    scanf("%d", &t);
    while(t--){
        scanf("%d%d%d%d", &n, &m, &L, &V);
        int T=0;
        for(int i=0; i<n; i++){
            int d, v, a, l, r;
            scanf("%d%d%d", &d, &v, &a);

            if(a==0 && v>V){
                ca[T++]={d, L};
            }
            if(a>0){
                if(v>V) l = d;
                else l = d+(V*V-v*v)/(2*a)+1;
                r = L;
                if(l<=r){
                    ca[T++]={l, r};
                }
            }
            if(a<0 && v>V){
                a = -a;
                l = d;
                r = d+(v*v-V*V-1)/(2*a);
                if(r>L) r = L;
                ca[T++] = {l, r};
            }
        }
        n = T;

        for(int i=0; i<m; i++){
            scanf("%d", p+i);
        }

        int ans=0, cnt=0;
        sort(ca, ca+n, cmp);
        int i=0, j=0, last=-1;
        while(i<n){
            if(ca[i].l>last){
                while(j<m && p[j]<=ca[i].r) j++;j--;
                if(p[j]>=ca[i].l){
                    cnt++;
                    last = p[j];
                    ans++;
                }
            }else ans++;
            i++;
        }
        printf("%d %d\n", ans, m-cnt);
    }
    return 0;
}
//16:53
